from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.schedulers.asyncio import AsyncIOScheduler


def setup_scheduler():
    job_stores = {
        "default": RedisJobStore(
            jobs_key="dispatched_trips_jobs", run_times_key="dispatched_trips_running"
        )
    }
    scheduler = AsyncIOScheduler(
        job_stores=job_stores,
        job_defaults={"max_instances": 1},
        timezone="Europe/Moscow",
    )
    return scheduler
